/*
 * Copyright 2004 original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jbfilter.impl;

import org.jbfilter.core.CleaningStrategy;
import org.jbfilter.core.JbfilterComparatorKeyword;
import org.jbfilter.core.fcomps.single.CompareFilterComponent;

abstract class _CompareFilterComponentImpl<E, T>
	extends _SingleFilterComponentImpl <E, T>
	implements CompareFilterComponent<E, T> {

	private JbfilterComparatorKeyword comparatorKeyword;
	private JbfilterComparatorKeyword comparatorKeywordCleanValue = null;
	
	// constructors
	_CompareFilterComponentImpl() {
		super();
		init();
	}
	_CompareFilterComponentImpl(String id) {
		super(id);
		init();
	}

	private void init() {
		comparatorKeyword = getComparatorKeywordAtStart();
	}
	@Override
	public void setComparatorKeyword(JbfilterComparatorKeyword comparatorKeyword) {
		if (comparatorKeyword == null) {
			throw new NullPointerException("comparatorKeyword cannot be null.");
		}
		this.comparatorKeyword = comparatorKeyword;
	}

	@Override
	public JbfilterComparatorKeyword getComparatorKeyword() {
		return comparatorKeyword;
	}

	@Override
	public void setComparatorKeywordCleanValue(JbfilterComparatorKeyword comparatorKeywordCleanValue) {
		this.comparatorKeywordCleanValue = comparatorKeywordCleanValue;
	}

	@Override
	public JbfilterComparatorKeyword getComparatorKeywordCleanValue() {
		return comparatorKeywordCleanValue;
	}

	@Override
	protected CleaningStrategy getDefaultCleaningStrategy() {
		return _DefaultCleaningStrategies.getCompareFilterComponentCleaningStrategy(this);
	}
	protected JbfilterComparatorKeyword getComparatorKeywordAtStart() {
		return JbfilterComparatorKeyword.gt;
	}

}
